package com.travel.service.impl;

import com.travel.dao.ProductDao;
import com.travel.domain.Product;
import com.travel.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;

    /**
     * 查询所有商品
     * @return
     */
    @Override
    public List<Product> findAll()  throws Exception {
        return productDao.findAll();
    }

    /**
     *添加一个商品
     * @param product
     */
    public void saveProduct(Product product)  throws Exception{
        productDao.saveProduct(product);
    }

    @Override
    public Product findByid(String id)  throws Exception {
        return productDao.findById(id);
    }
}
